package com.doudoukeji.service.Activity.disclaimer;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;

import com.doudoukeji.service.Activity.mvp.MainActivity;
import com.doudoukeji.service.R;
import com.doudoukeji.service.Utils.SharedPreferencesUtils;
import com.sanhai.android.mvp.BaseActivity;
import com.sanhai.android.mvp.EduActivity;

/**
 * @version 2.0
 * @类描述：免责声明
 * @项目名称：ddgh
 * @类名称： DisclaimerActivity
 * @包名称： com.doudoukeji.service.Activity.disclaimer
 * @创建人： zhanjunjie
 * @创建时间：2016/3/15 13:50
 * @修改人：
 * @修改时间：2016/3/15 13:50
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class DisclaimerActivity extends EduActivity {

    private WebView mWebView;
    private Button mBtnConfirm, mBtnBack;
    private Handler mHandler = new Handler();
    private Context context;
    private TextView mTvTitle;

    @Override
    public void init() {
        // 实例当前界面
        initView();
    }

    @Override
    public void onClickEvent(View view) {
        SharedPreferencesUtils.setParam(DisclaimerActivity.this, "READ", "1");
        Intent intent = new Intent(DisclaimerActivity.this, MainActivity.class);
        startActivity(intent);
        DisclaimerActivity.this.finish();
    }

    @Override
    public void setContentLayout() {
        setContentView(R.layout.activity_disclaimer);
    }

    // 实例化当前界面
    @SuppressLint("JavascriptInterface")
    public void initView() {
        mBtnBack = (Button) findViewById(R.id.btn_back);
        mBtnBack.setVisibility(View.GONE);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mTvTitle.setText("免责声明");
        mWebView = (WebView) findViewById(R.id.web);
        mBtnConfirm = (Button) findViewById(R.id.btn_confirm);
        mBtnConfirm.setOnClickListener(this);
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        mWebView.addJavascriptInterface(new Object() {
            @SuppressWarnings("unused")
            public void clickOnAndroid() {
                mHandler.post(new Runnable() {
                    public void run() {
                        mWebView.loadUrl("javascript:wave()");
                    }
                });
            }
        }, "demo");

        mWebView.loadUrl("file:///android_asset/main.html");
    }
}
